﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WindowsGame1
{
  
    class ColorMapper
    {
        /// <summary>
        /// used color scale
        /// </summary>
        protected ColorScale _colorScale;
        /// <summary>
        /// minimum Value of parameter to be colored
        /// </summary>
        protected float _minVal;
        /// <summary>
        /// maximum Value of parameter to be colored
        /// </summary>
        protected float _maxVal;

        /// <summary>
        /// Constructor ColorMappe
        /// </summary>
        /// <param name="colorScale"></param>
        /// <param name="minVal"></param>
        /// <param name="maxVal"></param>
        public ColorMapper(ColorScale colorScale, float minVal, float maxVal)
        {
            _colorScale = colorScale;
            _minVal = minVal;
            _maxVal = maxVal;
            
        }

        /// <summary>
        /// returns color for value at a given position
        /// </summary>
        /// <param name="valueAt"></param>
        /// <returns></returns>
        public Color colorFor(float valueAt)
        {
            return _colorScale.calculateColor((valueAt-_minVal)/(_maxVal-_minVal));
        }
    }
}
